package com.example.ass7.collision;

import com.example.ass7.geometryprimitives.Counter;
import com.example.ass7.level.GameLevel;
import com.example.ass7.sprite.Ball;
import com.example.ass7.sprite.Block;
import com.example.ass7.sprite.Paddle;

/**
 * @author Meirav Ben Izhak
 */
public class PlayerKiller implements HitListener {
    private final GameLevel game;
    private final Counter numberOfLives;
    /**
     * @param game
     *            game
     * @param numberOfLives
     *            numberOfLives
     */
    public PlayerKiller(GameLevel game, Counter numberOfLives) {
        this.game = game;
        this.numberOfLives = numberOfLives;
    }

    // Blocks that are hit and reach 0 hit-points should be removed
    // from the game. Remember to remove this listener from the block
    // that is being removed from the game.
    @Override
    public void hitEvent(Block beingHit, Paddle beingHit2, Ball hitter) {
        hitter.removeFromGame(this.game);
        numberOfLives.decrease(1);
        game.stop();
        System.out.println("Ball has been removed!");
    }
}